const {add, getList,getListHome,details} = require("./add")
const cloud = require('wx-server-sdk')

cloud.init({
	// API 调用都保持和云函数当前所在环境一致
	env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
    // event,
    // openid: wxContext.OPENID,
    // appid: wxContext.APPID,
    // unionid: wxContext.UNIONID,
    // env: wxContext.ENV,
	const {
		action,
		data
	}=event
	console.log("event  ",event);
	
	console.log("action  ",action);
	console.log("data  ",data);
	
	if (action === "add") {
		const a=await add(data)
		return a
	}else if(action==="getList"){
		return await getList(data)
	}else if(action==="getListHome"){
		return await getListHome()
	}else if(action==="details"){
		return await details(data)
	}
	
	return data
}